package com.ibangnuo.manage.controller.employee;

import com.ibangnuo.api.employee.EmployeeControllerApi;
import com.ibangnuo.framework.domain.request.employee.EmployeeRequest;
import com.ibangnuo.framework.domain.request.employee.SalesmanQueryRequest;
import com.ibangnuo.framework.model.response.QueryResponseResult;
import com.ibangnuo.manage.service.employee.EmployeeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;
import java.util.Map;


/**
 * @Author:ly
 * @Data:2019/12/27 11:24
 * @Verdion:1.0
 */
@RestController
@RequestMapping("/adminEntity")
public class EmployeeController implements EmployeeControllerApi {

    @Autowired
    private EmployeeService employeeService;


    //员工查询
    @PostMapping("/adminQuery")
    @Override
    public QueryResponseResult query( @RequestBody EmployeeRequest employeeRequest) {
        return employeeService.query( employeeRequest);
    }

    //员工删除
    @Override
    @GetMapping("/delAdmin/{adminNumber}")
    public QueryResponseResult delAdmin(@PathVariable("adminNumber") String  adminNumber) {
        return employeeService.delAdmin(adminNumber);
    }

   //员工的添加
    @Override
    @PostMapping("/addEmployees")
    public QueryResponseResult addEmployees(@RequestBody EmployeeRequest employeeRequest) {
        return employeeService.addEmployees(employeeRequest);
    }

    //员工编辑
    @Override
    @PostMapping("/upAdmin")
    public QueryResponseResult upAdmin(@RequestBody EmployeeRequest employeeRequest) {
        return employeeService.editEmployees(employeeRequest);
    }

    //员工信息回显
    @Override
    @GetMapping("/findById/{id}")
    public QueryResponseResult findById(@PathVariable("id") String id) {

        return employeeService.findById(id);

    }

    //业绩查询
    @Override
    @PostMapping("/performanceEnquiry")
    public QueryResponseResult performanceEnquiry(@RequestBody SalesmanQueryRequest salesmanQueryRequest) {
        return employeeService.performanceEnquiry(salesmanQueryRequest);
    }

    //业务员流水
    @Override
    @PostMapping("/salemanWater")
    public QueryResponseResult salemanWater(@RequestBody SalesmanQueryRequest salesmanQueryRequest) {
        return employeeService.salemanWater(salesmanQueryRequest);
    }

    /**
     * 查询当前登录用户下的员工
     * @return
     */
    @GetMapping("/findAllByAgentId")
    @Override
    public QueryResponseResult findAllByAgentId() {
        return employeeService.findAllByAgentId();
    }


}
